/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2018-05-29 09:22:36
 * @Copyright: 2018 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.pbpm.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Lang;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.itttq.gshop.domain.po.ErpOrderDetailPo;
import com.itttq.gshop.pbpm.cmpt.mybatis.CustomInLanguage;
import com.itttq.gshop.pbpm.provider.ErpOrderDetailSqlProvider;

@Mapper
public interface IErpOrderDetailMapper {
	/**
	 * 新增ErpOrderDetailPo对象，并设置生成的ID到erpOrderDetail对象中
	 * 
	 * @param ErpOrderDetailPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@InsertProvider(type=ErpOrderDetailSqlProvider.class,  method="addErpOrderDetail") 
	@Options(useGeneratedKeys = true, keyProperty = "id")
	public Integer addErpOrderDetail(ErpOrderDetailPo erpOrderDetail);

	/**
	 * 更新ErpOrderDetailPo对象
	 * 
	 * @param erpOrderDetailPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@UpdateProvider(type=ErpOrderDetailSqlProvider.class,  method="updateErpOrderDetail") 
	public Integer updateErpOrderDetail(ErpOrderDetailPo erpOrderDetail);
	
	/**
	 * 根据ID删除ErpOrderDetailPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return Integer
	 */
	@DeleteProvider(type=ErpOrderDetailSqlProvider.class,  method="delErpOrderDetail") 
	public Integer delErpOrderDetailById(Integer id);

	/**
	 * 根据IDS删除ErpOrderDetailPo对象
	 * 
	 * @param ids
	 * @Author 迷蝶
	 * @return List<ErpOrderDetailPo>
	 */
	@Lang(CustomInLanguage.class)
	@Delete("DELETE FROM order_info WHERE id IN (#{ids})")
	public Integer delErpOrderDetailByIds(@Param("ids") List<Integer> ids);
	
	/**
	 * 根据条件查找ErpOrderDetailPo对象，默认根据ID降序
	 * 
	 * @param erpOrderDetailPo
	 * @Author 迷蝶
	 * @return List<ErpOrderDetailPo>
	 */
	@SelectProvider(type=ErpOrderDetailSqlProvider.class,  method="findErpOrderDetails") 
	public List<ErpOrderDetailPo> findErpOrderDetails(ErpOrderDetailPo erpOrderDetail);
	
	/**
	 * 根据条件查找记录总数
	 * 
	 * @param erpOrderDetailPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@SelectProvider(type=ErpOrderDetailSqlProvider.class,  method="findErpOrderDetailCount") 
	public Integer findErpOrderDetailCount(ErpOrderDetailPo erpOrderDetail);

	/**
	 * 根据ID查找ErpOrderDetailPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return ErpOrderDetailPo
	 */
	@SelectProvider(type=ErpOrderDetailSqlProvider.class,  method="findErpOrderDetailById") 
	public ErpOrderDetailPo findErpOrderDetailById(Integer id);
	
	/**
	 * 批量增加订单商品信息
	 * 
	 * @param map	
	 * @Author 迷蝶
	 * @return String
	 */
	@InsertProvider(type=ErpOrderDetailSqlProvider.class,  method="insertBatch") 
	public Integer insertBatch(final Map<String, List<ErpOrderDetailPo>> map);

	/**
	 * 根据订单ID集合查询订单商品数据
	 * 
	 * @param orderIds	订单ID集合
	 * @Author 迷蝶
	 * @return List<OrderWarePo>
	 */
	@Lang(CustomInLanguage.class)
	@Select("SELECT * FROM erp_order_detail WHERE erp_order_id IN (#{orderIds})")
	public List<ErpOrderDetailPo> findOrderDetailByOrderIds(@Param("orderIds") final List<Integer> orderIds);
}